<template>
	<view class="">
		<view class="" style="padding-bottom: 120rpx;">
			<view class="mainpadding ffffff">
				<view class="xiahuaxian flexbetween margin_top">
					<view class="ershiba nofonweight xiaohei">姓名</view>
					<input type="text" class="textright" placeholder="请输入" v-model="username" style="width: 80%;">
				</view>
				<!-- <view class="xiahuaxian flexbetween margin_top">
					<view class="ershiba nofonweight xiaohei">年龄</view>
					<input type="number" class="textright" placeholder="请输入" v-model="age" style="width: 80%;">
				</view> -->
				<view class="xiahuaxian flexbetween margin_top">
					<view class="ershiba nofonweight xiaohei">性别</view>
					<view class="flexright">
						<u-radio-group v-model="gender" placement="row" circle>
							<u-radio activeColor="#1ba95b" :customStyle="{marginRight: '30rpx'}" label="男"
								name="1"></u-radio>
							<u-radio activeColor="#1ba95b" label="女" name="2"></u-radio>
						</u-radio-group>
					</view>
				</view>
				<view class="xiahuaxian flexbetween margin_top">
					<view class="ershiba nofonweight xiaohei">联系电话</view>
					<input type="number" class="textright" placeholder="请输入" v-model="mobile" style="width: 80%;">
				</view>
				<view class="xiahuaxian flexbetween margin_top">
					<view class="ershiba nofonweight xiaohei">身份证号</view>
					<input type="text" class="textright" placeholder="请输入" v-model="idcard" style="width: 80%;">
				</view>
				<view class="ershiba nofonweight xiaohei margin_top">介绍</view>
				<view class="margin_top">
					<u--textarea v-model="des" placeholder="请输入" count></u--textarea>
				</view>
			</view>
		</view>
		<view class="gudingdb ffffff mainpadding">
			<view class="bigbtn" @click="submit">保存</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				des: "",
				mobile: "",
				gender: "1",
				age: "",
				idcard: "",
				listid: "",
				username:"",
				user_zbfapply_listid:""
			}
		},
		onLoad(options) {
			this.user_zbfapply_listid=options.user_zbfapply_listid
			if (options.id) {
				this.listid = options.id
				uni.setNavigationBarTitle({
					title:"编辑销售"
				})
				this.getDetail()
			}else{
				uni.setNavigationBarTitle({
					title:"添加销售"
				})
			}
		},
		methods: {
			getDetail() {
				httpRequest.request('/api/user/cgXsDetail', 'GET', {
					id: this.listid,
					user_zbfapply_id:this.user_zbfapply_listid
				}).then(res => {
					let data = res.data
					this.mobile = data.mobile
					this.des = data.des
					this.username = data.username
					this.age = data.age
					this.gender = data.gender.toString()
					this.idcard = data.idcard
				})
			},
			submit() {
				if (this.username == "") {
					httpRequest.toast("请输入销售名称")
					return false
				}
				// if (this.age == "") {
				// 	httpRequest.toast("请输入销售年龄")
				// 	return false
				// }
				if (this.idcard == "") {
					httpRequest.toast("请输入身份证号")
					return false
				}
				if (this.des == "") {
					httpRequest.toast("请输入介绍")
					return false
				}
				uni.showLoading({
					mask:true,
					title:"请稍后"
				})
				let url = "/api/user/addXsInfo"
				let data = {
					mobile: this.mobile,
					des: this.des,
					idcard: this.idcard,
					username: this.username,
					// age: this.age,
					gender: this.gender,
					user_zbfapply_id:this.user_zbfapply_listid
				}
				if (this.listid) {
					url = "/api/user/editJXsInfo"
					this.$set(data,"id",this.listid)
				}
				httpRequest.request(url, 'GET', data).then(res => {
					uni.hideLoading()
					httpRequest.toast(res.msg)
					if (res.code == 1) {
						setTimeout(() => {
							uni.navigateBack(1)
						}, 1000)
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.huibtn {
		background: #F9F9F9;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		padding: 15rpx 30rpx;
		font-size: 28rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #777777;
	}

	.lvbtn {
		background: #DFFFED;
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		padding: 15rpx 30rpx;
		font-size: 28rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #1BA95B;
	}

	.touxiang {
		width: 60rpx;
		height: 60rpx;
		border-radius: 50%;

		image {
			border-radius: 50%;
			width: 100%;
			height: 100%;
		}
	}

	.dizneo {
		height: 500rpx;
		overflow: auto;
	}

	.xiaolbtn {
		width: 112rpx;
		height: 48rpx;
		background: rgba(27, 169, 91, 0.1);
		border-radius: 24rpx 24rpx 24rpx 24rpx;
		font-size: 24rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #1BA95B;
		border: 2rpx solid #1BA95B;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	page {

		background: #F9F9F9;
	}

	.shanchu {
		position: absolute;
		top: -10rpx;
		right: -10rpx;
	}

	.shanchu2 {
		position: absolute;
		bottom: -10rpx;
		right: -50%;
		transform: translate(0, -50%);
	}

	.shilitu {
		width: 160rpx;
		height: 160rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.shangc {
		width: 160rpx;
		height: 160rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}
</style>